package com.sojson;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

import com.sojson.util.init.InitUtil;

/**
 * 启动类
 *
 * @author liu
 * @date 2021-09-13
 */
@SpringBootApplication
public class App extends SpringBootServletInitializer {

    /**
     * 打war包要让启动类继承SpringBootServletInitializer类并重写此方法
     * 或者再创建一个任意类继承SpringBootServletInitializer类并重写此方法(方法中的builder.sources(App.class)还是要指向这个启动类)
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(App.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(App.class, args);
        InitUtil.runEnd();
    }

}